﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using WebService.DAO;
using WebService.VO;

namespace WebService.BUS
{
    public class UserCommentBUS
    {
        UserCommentDAO usercmtDAO;
        public UserCommentBUS()
        {
            usercmtDAO = new UserCommentDAO();
        }

        /// <summary>
        /// Get Comment by Item
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns></returns>
        public DataTable getCommentByItem(int itemID)
        {
            DataTable dt = usercmtDAO.getCommentByItem(itemID);
            foreach (DataRow row in dt.Rows)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {


                    dt.Columns[i].ReadOnly = false;

                    if (string.IsNullOrEmpty(row[i].ToString()))
                    {
                        if (dt.Columns[i].DataType == typeof(string))
                            row[i] = "NULL";
                        else if (dt.Columns[i].DataType == typeof(int))
                            row[i] = new int();
                        else if (dt.Columns[i].DataType == typeof(DateTime))
                            row[i] = new DateTime();
                    }
                }
            }
            return dt;
        }

        /// <summary>
        /// Insert Comment
        /// </summary>
        /// <param name="comment"></param>
        public void insertComment(UserCommentVO comment)
        {
            usercmtDAO.insertComment(comment);
        }


    }
}